package thefirst.member.model;

import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import javax.annotation.Resource;

import org.mybatis.spring.SqlSessionTemplate;
import org.springframework.stereotype.Repository;

import thefirst.support.model.HelpVO;
import thefirst.support.model.NoticeVO;
/**
 * TeacherOfMemberDaoImpl
 * 	MemberDao를 implements한 클래스.
 *  회원들이면 공통적으로 가지고 있는 메서드를 
 *  선생님 회원에 맞게 overriding 을 진행.
 *  
 *  sqlSessionTemplate을 활용해 Data access.
 * @author kosta-00-30
 *
 */
@Repository
public class TeacherOfMemberDaoImpl implements MemberDao{
@Resource(name="sqlSessionTemplate")
	private SqlSessionTemplate sqlSessionTemplate;

@Override
public void registerMember(MemberVO mvo) throws SQLException {
	sqlSessionTemplate.insert("member.registerTeacher",mvo);
	}

@Override
public MemberVO showMember(MemberVO mvo) throws SQLException {
	return sqlSessionTemplate.selectOne("member.showTeacher", mvo);
}
@Override
public int isExistId(MemberVO mvo) throws SQLException {
	System.out.println("dao"+mvo);
	int result=sqlSessionTemplate.selectOne("member.isExistTeaId",mvo);
	System.out.println("dao:"+result);
	return result;
}	
/*@Override
public int upload(TeacherVO tvo) throws SQLException{
	return sqlSessionTemplate.insert("member.upload",tvo);
}*/
@Override
public int updateName(MemberVO mvo) throws SQLException {
	// TODO Auto-generated method stub
	return sqlSessionTemplate.update("member.updateTeacherName", mvo);
}

@Override
public int updateGender(MemberVO mvo) throws SQLException {
	// TODO Auto-generated method stub
	return sqlSessionTemplate.update("member.updateTeacherGender", mvo);
}	

@Override
public int updateTel(MemberVO mvo) throws SQLException {
	// TODO Auto-generated method stub
	return sqlSessionTemplate.update("member.updateTeacherTel", mvo);
}

@Override
public int updateEmail(MemberVO mvo) throws SQLException {
	// TODO Auto-generated method stub
	return sqlSessionTemplate.update("member.updateTeacherEmail", mvo);
}

@Override
public int updateHoperegion(MemberVO mvo) throws SQLException {
	// TODO Auto-generated method stub
	return sqlSessionTemplate.update("member.updateTeacherHoperegion", mvo);
}

public int updateHopesubject(TeacherVO tvo) throws SQLException {
	// TODO Auto-generated method stub
	return sqlSessionTemplate.update("member.updateTeacherHopesubject", tvo);
}

public int updateHopegender(TeacherVO tvo) throws SQLException {
	// TODO Auto-generated method stub
	return sqlSessionTemplate.update("member.updateTeacherHopegender", tvo);
}

public int updateAvailablestudent(TeacherVO tvo) throws SQLException {
	// TODO Auto-generated method stub
	return sqlSessionTemplate.update("member.updateTeacherAvailablestudent", tvo);
}

public int updateAvailableday(TeacherVO tvo) throws SQLException {
	// TODO Auto-generated method stub
	return sqlSessionTemplate.update("member.updateTeacherAvailableday", tvo);
}

public int updateAvailabletime(TeacherVO tvo) throws SQLException {
	// TODO Auto-generated method stub
	return sqlSessionTemplate.update("member.updateTeacherAvailabletime", tvo);
}

public int updateIntro(TeacherVO tvo) throws SQLException {
	// TODO Auto-generated method stub
	return sqlSessionTemplate.update("member.updateTeacherIntro", tvo);
}

public int updateUniversity(TeacherVO tvo) throws SQLException {
	// TODO Auto-generated method stub
	return sqlSessionTemplate.update("member.updateTeacherUniversity", tvo);
}

@Override
public MemberVO login(MemberVO mvo) throws SQLException {
	return sqlSessionTemplate.selectOne("member.loginteacher", mvo);
}
/**
 * 페이징 처리를 위하여 선생님회원의 수를 가져온다.
 */
@Override
public int selectTotalMemberCount() throws SQLException {
	// TODO Auto-generated method stub
	return 0;
}
/**
 * 페이징 처리를 위하여 선생님회원의 해당페이지 리스트를 가져온다. 
 */
@Override
public List<?> getMemberListBasic(int pageNo) throws SQLException {
	// TODO Auto-generated method stub
	return null;

}

@Override
public void withdrawalMember(MemberVO mvo) throws SQLException {
	// TODO Auto-generated method stub
	sqlSessionTemplate.update("member.withdrawalTeacher", mvo);

}
/**
 * mvo로 들어온 값(name,email)으로 선생님의 id를 가져온다.
 */
@Override
public String findIdByNameEmail(MemberVO mvo) throws SQLException {
	// TODO Auto-generated method stub
	return sqlSessionTemplate.selectOne("member.findTeacherIdByNameEmail", mvo);
}

@Override
public List<?> getListForAdmin(String pageNo) throws SQLException {
	// TODO Auto-generated method stub
	return null;
}

@Override
public MemberVO findQPassByIdEmail(MemberVO mvo) throws SQLException {
	// TODO Auto-generated method stub
	return sqlSessionTemplate.selectOne("member.findTeacherQPassByIdEmail",mvo);
}

@Override
public String findPasswordByQnAPass(MemberVO mvo) throws SQLException {
	// TODO Auto-generated method stub
	return sqlSessionTemplate.selectOne("member.findTeacherPasswordByQnAPass",mvo);
}


@Override
public List<MyHelpVO> getMyHelpList(MyHelpVO myHelpVO) throws SQLException {
	// TODO Auto-generated method stub
	return sqlSessionTemplate.selectList("member.myHelpTeacherList",myHelpVO);
}

}
